var app = getApp();
const domainUrl = app.globalData.domainUrl
Page({
  data:{
    imageSrc:'',
    imageHeight:560,
    imageFlag:'0',
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    console.log(options);
    wx.getSystemInfo({
      success: function(res) {
          console.log("width="+res.windowWidth+", height="+res.windowHeight);
          that.setData({
            imageSrc:options.imagepath,
            imageHeight:res.windowHeight*0.98,
            imageFlag:'0'
        });
      }
    })
  },
  deletePhoto:function(event){
    var that = this;
    console.log('用户点击确定');
    console.log(that);
    let flag = that.data.imageFlag;
    if(flag == "0"){
      flag = "1"
    } else {
      flag = "0"
    }
    let indexStart = that.data.imageSrc.lastIndexOf('/');
    let indexEnd = that.data.imageSrc.lastIndexOf('.');
    let id = that.data.imageSrc.substring(indexStart+1, indexEnd);

    wx.request({
      url: domainUrl+'shuihuCardSingle?flag='+flag+'&id='+id,
      success: function (res) {
        console.log(res);
        that.setData({
          imageSrc:res.data,
          imageFlag:flag
        })
      }
    });
  }
})